|
Session Start (MSN - FONZIE - Rise From Your Grave!:B I G J O H N O @ Uni): Tue Nov 23 18:49:49 2004
*** INTRO *** JOHNO : Hey Fonzie :) A fan of altered beast i see! :) FONZIE : hi FONZIE : (not a real ab fan) JOHNO : damn hehe, i love that game. :) FONZIE : just heard the remix JOHNO : anyway m8, i was hoping you could give me a few pointers where to start with learning to program megadrive/genesis games. FONZIE : Sure JOHNO : :) where the best place to start? ive been looking through some links on your site so far, doing a bit of reading FONZIE : have you already programmed in C? JOHNO : some c, mainly C++ FONZIE : and some 68K ASM ? JOHNO : Ive done some processor programming, with ARM7, but not on 68k ASM. I'm readin up on that now FONZIE : héhé, ARM from gba? JOHNO : hehe, no, it was part of my university course. Sir Robin Saxby who is the chairman of ARM7 qualified from my department, so we get a lot of the equipment free from them, for teaching purposes FONZIE : ok cool FONZIE : Have you used GCC before? FONZIE : (i start with some questions, sorry of that) JOHNO : no i havent FONZIE : So you want to make a game ! JOHNO : yeah, i dont expect to make sonic 3 in a day. i kno i need to start small :) FONZIE : Normal FONZIE : Welcome to the next level man ! JOHNO : very small >_< cheers FONZIE : Just to say that C programming is easy with segagenesis JOHNO : yeah, i read it was best if you knew C FONZIE : because, once you understood the mechanism of the VDP (video display processor) you can do all your stuff only using 2 pointers (*pw and *pl, lol) FONZIE : But you need to understand the vdp ^^ FONZIE : Quite hard i agree but so simple when you know JOHNO : sounds cool :) need to read some info then ^_^ FONZIE : http://fvring.free.digitartstudio.com/index.php?main=cga&sub=mdd&ssub=doc FONZIE : here are some docs FONZIE : Genesis Technical Overview is the reference documentation JOHNO : (Y) FONZIE : (you have 99% of genesis mechanisms on it) FONZIE : maybe you have some minutes, so i can explain you how the genesis works (better than reading the doc) JOHNO : before we go ahead, i'd just like 2 thank you for your time, i appreciate it FONZIE : np FONZIE : i'm so happy to see new guys joining the community JOHNO : hehe, ive been a MD colector for about 15yrs, its about time i took it to the next level! FONZIE : sure FONZIE : So, in fact the genesis is very simple for programming FONZIE : between GB and NES FONZIE : and GB is the easyer system ever JOHNO : hehe ok FONZIE : So don't worry if its hard first, it will be easy after JOHNO : ok, i will try my best *** TECH OVERVIEW *** FONZIE : In genesis you have A cartridge, a ram, a vdp and a IO controller (and a z80 with its own ram and 2 sound chip but it doesn't matter for now) FONZIE : the cartridge (4MB max) and ram (64KB) are 16bits JOHNO : ok FONZIE : (16 bit data bus) JOHNO : yeah (Y) FONZIE : The 68k is 32bit but with 16bit bus and @ 8 mhz FONZIE : it has direct acces (without cycle loose) on the whole system JOHNO : just to clear this up, what exactly is the 68k? FONZIE : motorola 68000 FONZIE : the main processor JOHNO : ah, ok (Y) FONZIE : you don't know 68000 series? JOHNO : not in great detail, i'll have to learn this and study it FONZIE : i don't know it too but its a very very used microprocessor in the 1985-1995 JOHNO : ok FONZIE : so, on startup FONZIE : the 68K directly go in the start of the ROM (cartridge) FONZIE : and execute code FONZIE : from 0x00000 JOHNO : yer (Y) FONZIE : (there is a rom header needed but it doesn't matter) FONZIE : Then, to display a thing, you need to use the VDP JOHNO : ok *** VDP OVERVIEW *** FONZIE : VDP is a VideoDisplayProcessor (hardware display) running at 53mhz and having 64kB of VRAM FONZIE : this VDP has some 25 registers (acces possible from 68K) to parameter the display FONZIE : (GenesisTechnicalOverview make a summary of all these 25 registers) JOHNO : ok, understand so far :) JOHNO : ok, i'll read that later FONZIE : exemple of register: FONZIE : Display ON/OFF ^^ JOHNO : heh FONZIE : or Screen320px width or 256 pixels width FONZIE : you see? Very simple things FONZIE : So as i said, the VDP have 64KB of VRAM (can't be accessed from 68K) FONZIE : in this vram is situated: FONZIE : -Patterns (tiles) FONZIE : -ScrollsHorizontal values JOHNO : (Y) FONZIE : -Planes (Layers A and B and Window) table FONZIE : -Sprite list FONZIE : (note that scroll Vertical is stored on a external register, not in VRAM) FONZIE : (scroll horizontal is in VRAM) JOHNO : ok :) FONZIE : so you can't acces on this 64KB vram from 68K FONZIE : so, problem, isn't it?, lol JOHNO : >_< FONZIE : So, since sega is clever FONZIE : they added a FIFO in the VDP FONZIE : this FIFO is defined into 2 registers, one Adress and one Data. FONZIE : you know what is a FIFO? JOHNO : yup JOHNO : First In First Out Principal FONZIE : héhé FONZIE : So, FONZIE : to write a thing in vram from 68k FONZIE : you put the VRAM adress to write in the Adress FIFO register (AKA CTRL port) JOHNO : ok FONZIE : and you fill the data to write in vram in the Data Fifo register (aka DATA port) FONZIE : and the fifo automaticaly increase FONZIE : (you don't have to redefine the adress for each write) JOHNO : (Y) FONZIE : So, thats cool FONZIE : you understood every thing! JOHNO : yup JOHNO : yer :D im surprised :D FONZIE : btw: the 64KB ram is also known as WorkRam for the 68K FONZIE : (i'm not talking about the 64KB VRAM° JOHNO : ok, i'll make a note of that *** VDP TILES *** FONZIE : so, i can explain you how works the VDP (to display a thing) FONZIE : or if you preffer me t o tell you where to get compîlation tools FONZIE : just ask JOHNO : what do u think is best to do now? read more explanation or have a go? FONZIE : umm FONZIE : i can explain you planes FONZIE : (layers) FONZIE : and sprites if you want JOHNO : if you think that it best, yes please :) FONZIE : so, (i'll talk about VRAM) FONZIE : in VRAM you have patterns FONZIE : genesis VDP grafics files are names "tiles" (patterns) FONZIE : a tile is a 8*8 pixel cube FONZIE : (square) JOHNO : ok FONZIE : this cube is coded like that: FONZIE : 0x12345678 FONZIE : 0x12345678 FONZIE : 0x12345678 FONZIE : 0x12345678 FONZIE : 0x12345678 FONZIE : 0x12345678 FONZIE : 0x12345678 FONZIE : 0x12345678 FONZIE : you see the 8*8 pixels? JOHNO : i do, yes FONZIE : so 1 will show as color 1 in palette FONZIE : F show as color 15 in palette FONZIE : 0 is show as transparency color JOHNO : (Y) FONZIE : so a tile takes 4*8 bytes FONZIE : 32bytes of vram JOHNO : (Y) FONZIE : so since you have some 64KB of VRAM, you can store a max of 2048tiles JOHNO : i understand hehe FONZIE : so the VRAM is divided onto 2048 tiles positions JOHNO : ok FONZIE : Now FONZIE : tile is not enough to display a thing ^^ *** VDP PLANES *** FONZIE : The genesis VDP as 3 layers FONZIE : called Planes JOHNO : ah ok FONZIE : Plane B (bg plane) planeA(fg plane) and plane W (fgplane but used as remplacemetn of PlaneA on a part of the screen) FONZIE : PlaneA,B and W are in fact big arrays (of words) FONZIE : (situated in VRAM) JOHNO : ok JOHNO : btw, ur a really good teacher :) FONZIE : each cell of plane can host a tile number FONZIE : (just take in account that a plane are 64 cells width and 32 cells height) JOHNO : will do FONZIE : so you can define 64 tiles numbers in a plane width FONZIE : and since a tile is 8pixels width FONZIE : it makes a 512 pixel width plane FONZIE : i said "tile number" FONZIE : because its a real number FONZIE : not the full tile data (32bytes) FONZIE : just the number of the tile in VRAM JOHNO : ok FONZIE : like 0,1,3,4,8,45,2047 FONZIE : it will display on plane , tile number 0, then 1 then 3.... JOHNO : yes, i see FONZIE : ok cool FONZIE : so each plane cell contains a tile number FONZIE : but also some others infos FONZIE : (each cell is a word > 16bit) JOHNO : ok FONZIE : from bit 0 to 11, its the tile number (in vram) JOHNO : ok FONZIE : (note that you can make 2048 possibilities with 11 bits, wow magic ^^) JOHNO : hehe wahoo :D FONZIE : the bits (starting from bit0) 11 and 12 are tile flip FONZIE : horizontal and vertical flip JOHNO : what u mean by flip? FONZIE : (so you can reverse some tiles in the plane) JOHNO : ah ok FONZIE : bits 13and 14 is pallete number FONZIE : (there are 4 palettes of 16 colors in the genesis vdp) FONZIE : so you can assign a color palette per tile of plane JOHNO : (Y) FONZIE : and the bit 15 is known as Priority bit FONZIE : if 1, plane B tile go over PlaneA tile in 0 FONZIE : you know, to make some priorities of display between plane A and B JOHNO : ok FONZIE : (this bit can also be used to make some cool shadow effects, but you'ill learn by yourself) JOHNO : ok :) FONZIE : so FONZIE : each plane has a scroll vertical and horizontal value FONZIE : and can be scrolled infinitively FONZIE : (it repeats) JOHNO : i see FONZIE : when you scroll horizontal 512pixels, you get like if it was scroll was 0 JOHNO : ok FONZIE : now, each plane has various modes FONZIE : 64*32 cells FONZIE : 32*32 cells FONZIE : 32*64 cells FONZIE : 128*32 cells FONZIE : note that 64*32 cells takes only 64*32*2 bytes of vram which is cool FONZIE : 4KB JOHNO : cool FONZIE : so for plane A and B and W you lose only 12KB of vram *** VDP SPRITES *** FONZIE : Now, sprites ! JOHNO : nice FONZIE : There is a sprite table FONZIE : (80 sprites) JOHNO : ok FONZIE : and each sprite takes 4*2 bytes JOHNO : ok FONZIE : So, FONZIE : 1st sprite of list is foreground FONZIE : last is drawed in last FONZIE : (background) FONZIE : yes i know its illogical FONZIE : but its a vdp tricks to go faster ^^ JOHNO : ok FONZIE : So FONZIE : Each sprite is separated onto 4 words FONZIE : 1st word FONZIE : PosY FONZIE : (screen pos start at 128,128) FONZIE : 2nd word : TileLink+Size of tile FONZIE : 3rd word: starting tile in vram (exactly like the plane cell ) FONZIE : (starting tile of the sprite) JOHNO : ok FONZIE : btw size goes from 0x0 to 0xF FONZIE : (1*1 to 4*4 tile size) JOHNO : ok FONZIE : and last word is PosX FONZIE : btw, the 2nd word is designed like that : 0x0SNN FONZIE : S: size FONZIE : NN : link to the next sprite in list to draw (basicaly the next sprite in the list) JOHNO : ok, thanks FONZIE : So Word3 is exactly the same functions as the one used in PlaneCells FONZIE : but you define only the starting tile of the sprites JOHNO : ok m8 FONZIE : the other one (if sprite is bigger than 1*1) are automaticaly take in the vram at the fallowing FONZIE : you'll experiement this later ^^ JOHNO : i will yes heh *** VDP MISC *** FONZIE : So there is also the HorizontalScrool definition FONZIE : (taking some bytes in vram) FONZIE : and the scroll is interlaced FONZIE : first word, scroll for plane B, second word, scroll for plane A ... FONZIE : Also note that the VRAM adress for PlaneA and Plane B and scrollH and Sprites and PlaneW JOHNO : ok FONZIE : are defined in the VDP registers JOHNO : ok FONZIE : like , PlaneA starting @ 0xC000 in vram JOHNO : (Y) FONZIE : and when you write "2" @ 0xC000 FONZIE : it display the tile number 2 on top left border of the plane FONZIE : ;-) *** FIRST CODE *** FONZIE : So what i can advice you FONZIE : is to download SGCC (crap C compilator but very simple of use) JOHNO : wow, thats a lot of info! good job i took lots of notes :D FONZIE : http://fvring.free.digitartstudio.com/index.php?main=cga&sub=mdd&ssub=tlz FONZIE : sgcc is on this page JOHNO : :) FONZIE : Then just download Technical Overview demo: FONZIE : http://fvring.free.digitartstudio.com/index.php?main=cga&sub=mdd&ssub=dmo FONZIE : (special for SGCC) FONZIE : then you put the sources of techoverview and sgcc packtage on the same folder JOHNO : thank you, i'll get them now. FONZIE : and you type "make" on a msdos prompt FONZIE : and théoricaly gcc compile all the demo and output a new . bin ^^ FONZIE : (theoricaly) FONZIE : LOL FONZIE : then in the technical demo FONZIE : (i tell you the content of the sources) FONZIE : sega.s is the rom header FONZIE : demo1.c is the whole C code of the demo (main) FONZIE : fvrlib.c is the lib used in the demo FONZIE : (to display things without tons of code) FONZIE : charset.s contains some tiles (pattern) FONZIE : for the demo FONZIE : then just look @ the main functions and trace all the functions called FONZIE : and you'll be a god in 1 day JOHNO : hehe JOHNO : thank you SOOOOOOOO mcuh for all this help, you should lecture this! :D FONZIE : btw: its a crap coded demo, and in SGCC int is 16bit char is 8bit and long is 32bit FONZIE : No problem FONZIE : Just take this as an advice: just start to code some demos with sgcc JOHNO : "SGCC Téléchargez la version complète" file is unavailable JOHNO : i will, if i can get it hehe FONZIE : ? FONZIE : wow FONZIE : just download the mini packtage JOHNO : ok FONZIE : and when you'll get bored of sgcc bugs (because it makes tons of bugs) just go on GCC and make us a kicking game! JOHNO : hehe, im sure that'll be some time ahead, but I'll try :) FONZIE : Btw: go here and download tools>gensKmod http://www.consoledev.fr.st/ it will be very easy for you to see the vdp vram FONZIE : and to understand all i told you (planeA; B, sprites...) JOHNO : ok :) i cant wait to learn this softwares FONZIE : ;-) FONZIE : If youre a real C coder , it will be easy to make some cool games. JOHNO : as i said, only a bit of C, mainly C++. JOHNO : main file is scarey! lol FONZIE : yes FONZIE : but did you saw the demo? FONZIE : the demo is very very linear and show many many things JOHNO : i did make, JOHNO : now i should run the file? FONZIE : yes FONZIE : using gensKmod FONZIE : ^^ JOHNO : ok :) FONZIE : to test if sgcc is working, just edit some text in the demo and compile and reload the demo in gens JOHNO : it just stays like that FONZIE : press C to continue FONZIE : or start (i don't remember) JOHNO : ah :P FONZIE : (in the demo, lol) JOHNO : coooool! JOHNO : wow, this is a lot to take in FONZIE : If you have any question about the code FONZIE : just ask JOHNO : i guess ive just gotta try and work out what each line does, atm its just a mass of code. im lookin at the tech deomo still at the moment FONZIE : just use kmod functions (CPU > Debug >Genesis > VDP) JOHNO : yeah, it shows the colours FONZIE : and the vram content (tile decoded) FONZIE : you'll notice the planes data (at the end) JOHNO : yeah, seen that |